//
//  MineViewController.m
//  WideHelp
//
//  Created by ENERGY on 2018/8/6.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "MineViewController.h"
#import "MineTableViewCell.h"
#import "JoinProjectViewController.h"
#import "HelpRecordViewController.h"
#import "AccountDetailViewController.h"
#import "MyProjectDetailViewController.h"
#import "MyCertificateViewController.h"
#import "AuthenticationViewController.h"
#import "AddFamilyViewController.h"
#import "SettingViewController.h"
#import "LoginViewController.h"

#define authenticationH 35/WIDTH_6_SCALE

@interface MineViewController ()<UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate>
@property (nonatomic, strong)UITableView * tableView;
@property (nonatomic, strong)UIView * headerView;
@property (nonatomic, strong)UIImageView * iconImg;//头像
@property (nonatomic, strong)UILabel * nameLab;//名字
//@property (nonatomic, strong)UILabel * authenticationLab;//实名认证
@property (nonatomic, strong)UILabel * joinDaysContentLab;//加入天数
@property (nonatomic, strong)UILabel * helpPersonsContentLab;//帮助人数
@property (nonatomic, strong)UILabel * accountContentLab;//余额
@property (nonatomic, strong)UILabel * validNumsLab;//生效人数
@property (nonatomic, strong)NSDictionary * topDataDic;
@property (nonatomic, strong)NSDate * date;//当前日期
@property (nonatomic, strong)UIImageView * diamondImg;//钻石图案
@property (nonatomic, strong)UIButton * authenticationBtn;//实名认证按钮
@end

@implementation MineViewController(networking)
- (void)getUserInfo{
    NSDictionary * dic = @{
                           @"userId":[UserModel sharedInstanced].userID,
                           @"cookie":[UserModel sharedInstanced].cookie,
                           };
    [self showprogressHUD];
    [[AFAppDotNetAPIClient sharedClient] POST:@"user/getUserInfo" parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [self hiddenProgressHUD];
        if ([responseObject[@"msg"] isEqualToString:@"success"]) {
            if ([responseObject[@"list"] count]>0) {
                self.topDataDic = responseObject[@"list"][0];
                if ([self.topDataDic[@"is_real_name"] isEqualToString:@"1"]) {//已认证
                    self.nameLab.text = [NSString stringWithFormat:@"%@", self.topDataDic[@"realname"]];
                    [self button:self.authenticationBtn withBGColor:[UIColor clearColor] withLayerBorderColor:nil withLayerBorderWith:0 withCornerRadius:0 withMasksToBounds:NO withViwe:self.headerView];
                    [self.authenticationBtn setTitle:@"已认证" forState:UIControlStateNormal];
                    [self.authenticationBtn setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
                }else{
                    self.nameLab.text = [NSString stringWithFormat:@"%@", self.topDataDic[@"nickname"]];
                    [self button:self.authenticationBtn withBGColor:[UIColor clearColor] withLayerBorderColor:getColor(greenBGColor) withLayerBorderWith:1/WIDTH_6_SCALE withCornerRadius:authenticationH/2 withMasksToBounds:YES withViwe:self.headerView];
                    [self.authenticationBtn setTitle:@"实名认证" forState:UIControlStateNormal];
                    [self.authenticationBtn setTitleColor:getColor(greenBGColor)  forState:UIControlStateNormal];
                }
                self.accountContentLab.text = [NSString stringWithFormat:@"%@", self.topDataDic[@"u_balance"]];
                self.helpPersonsContentLab.text = [NSString stringWithFormat:@"%@", self.topDataDic[@"help_num"]];
                //由NSString 转换为NSDate:
                NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                NSDate *lastdate = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@", self.topDataDic[@"createtime"]]];
                self.joinDaysContentLab.text = [NSString stringWithFormat:@"%i", (int)[[self class] numberOfDaysWithFromDate:lastdate toDate:self.date]];
                if ([self.topDataDic[@"is_vip"] isEqualToString:@"0"]) {
                    self.nameLab.frame = CGRectMake(15/WIDTH_6_SCALE, self.iconImg.bottom + 13/WIDTH_6_SCALE, SCREEN_WIDTH - 30/WIDTH_6_SCALE, 17/WIDTH_6_SCALE);
                    self.diamondImg.hidden = YES;
                }else{
                    self.nameLab.frame = CGRectMake(0, self.iconImg.bottom + 13/WIDTH_6_SCALE, [[self class] contentLabelWidth:self.nameLab.text], 17/WIDTH_6_SCALE);
                    self.nameLab.centerX = self.view.centerX;
                    //钻石图案
                    self.diamondImg.frame = CGRectMake(self.nameLab.right + 5/WIDTH_6_SCALE, self.nameLab.top, self.nameLab.height, self.nameLab.height);
                    self.diamondImg.hidden = NO;
                }
            }
        }else{
            ShowMessage(responseObject[@"msg"]);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self hiddenProgressHUD];
        [self showError:error];
        LoginViewController * loginVC = [[LoginViewController alloc] init];
        [self.navigationController presentViewController:loginVC animated:YES completion:nil];
    }];
}

@end
@implementation MineViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    if ([[UserModel sharedInstanced].userID isEqualToString:@""]) {
        LoginViewController * loginVC = [[LoginViewController alloc] init];
        [self.navigationController presentViewController:loginVC animated:YES completion:nil];
    }
    self.navigationController.delegate = self;
    [self getUserInfo];//网络接口
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"";
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self.view addSubview:self.tableView];
    
    //获取当前时间日期
    self.date = [NSDate date];
    NSDateFormatter *format1=[[NSDateFormatter alloc] init];
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
    [format1 setTimeZone:timeZone];
    [format1 setDateFormat:@"yyyy-MM-dd hh:mm:ss Z"];
    NSString *dateStr;
    dateStr=[format1 stringFromDate:self.date];
    NSLog(@"当前时间日期：%@",dateStr);
}
#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    BOOL isHomePage = [viewController isKindOfClass:[self class]];
    [self.navigationController setNavigationBarHidden:isHomePage animated:YES];
}
#pragma mark - init
- (NSDictionary *)topDataDic{
    if (!_topDataDic) {
        _topDataDic = @{}.mutableCopy;
    }return _topDataDic;
}
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - TABBAR_HEIGHT) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerClass:[MineTableViewCell class] forCellReuseIdentifier:NSStringFromClass([MineTableViewCell class])];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.tableHeaderView = self.headerView;
        _tableView.rowHeight = 153/WIDTH_6_SCALE;
    }return _tableView;
}
- (UIView *)headerView{
    if (!_headerView) {
        _headerView = [[UIView alloc] init];
        if (Is_Iphone_X) {
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 368/WIDTH_6_SCALE + 24);
        }else{
            _headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 368/WIDTH_6_SCALE);
        }
        _headerView.backgroundColor = getColor(@"f5f5f5");
        [self setUpHeaderViews];//头部控件
    }return _headerView;
}
- (void)setUpHeaderViews{
    //背景图片
    UIImageView * bgImg = [[UIImageView alloc] init];
    bgImg.image = [UIImage imageNamed:@"maself_bg"];
    [_headerView addSubview:bgImg];
    //标题
    UILabel * titleLab = [[UILabel alloc] init];
    if (Is_Iphone_X) {
        bgImg.frame = CGRectMake(0, 0, SCREEN_WIDTH, 317/WIDTH_6_SCALE + 24);
        titleLab.frame = CGRectMake(0, 34/WIDTH_6_SCALE + 24, SCREEN_WIDTH, 18/WIDTH_6_SCALE);
    }else{
        bgImg.frame = CGRectMake(0, 0, SCREEN_WIDTH, 317/WIDTH_6_SCALE);
        titleLab.frame = CGRectMake(0, 34/WIDTH_6_SCALE, SCREEN_WIDTH, 18/WIDTH_6_SCALE);
    }
    [self label:titleLab withFont:DEF_FontSize_12 withText:@"我的" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentCenter withView:_headerView withBGColor:[UIColor clearColor]];
    //设置按钮
    int settingBtnW = 21/WIDTH_6_SCALE;
    UIButton * settingBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - settingBtnW - 15/WIDTH_6_SCALE, 0, settingBtnW, settingBtnW)];
    settingBtn.centerY = titleLab.centerY;
    [settingBtn setBackgroundImage:[UIImage imageNamed:@"set_icon"] forState:UIControlStateNormal];
    [settingBtn addTarget:self action:@selector(settingBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [_headerView addSubview:settingBtn];
    //白色图片背景
    UIImageView * whiteImg = [[UIImageView alloc] initWithFrame:CGRectMake(15/WIDTH_6_SCALE, titleLab.bottom + 41/WIDTH_6_SCALE, SCREEN_WIDTH - 30/WIDTH_6_SCALE, 113/WIDTH_6_SCALE)];
//    whiteImg.backgroundColor = [UIColor yellowColor];
    whiteImg.image = [UIImage imageNamed:@"myself_x_bg"];
    //得到view的遮罩路径
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:whiteImg.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10,10)];
    //创建 layer
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = whiteImg.bounds;
    //赋值
    maskLayer.path = maskPath.CGPath;
    whiteImg.layer.mask = maskLayer;
    [_headerView addSubview:whiteImg];
    //头像
    self.iconImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 51/WIDTH_6_SCALE, 51/WIDTH_6_SCALE)];
    self.iconImg.image = [UIImage imageNamed:@"head_login_icon"];
    self.iconImg.centerX = self.view.centerX;
    self.iconImg.centerY = whiteImg.top;
    [_headerView addSubview:self.iconImg];
    //钻石图案
    self.diamondImg = [[UIImageView alloc] init];
    self.diamondImg.image = [UIImage imageNamed:@"VIP_icon"];
    [self.headerView addSubview:self.diamondImg];
    //名字
    self.nameLab = [[UILabel alloc] init];
    self.nameLab.frame = CGRectMake(whiteImg.left, self.iconImg.bottom + 13/WIDTH_6_SCALE, whiteImg.width, 17/WIDTH_6_SCALE);
    [self label:self.nameLab withFont:DEF_FontSize_16 withText:@"用户名" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentCenter withView:_headerView withBGColor:[UIColor clearColor]];

    //实名认证
    UIButton * authenticationBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.nameLab.bottom + 13/WIDTH_6_SCALE, 111/WIDTH_6_SCALE, authenticationH)];
    authenticationBtn.centerX = _headerView.centerX;
    [self button:authenticationBtn withBGColor:[UIColor clearColor] withLayerBorderColor:getColor(greenBGColor) withLayerBorderWith:1/WIDTH_6_SCALE withCornerRadius:authenticationH/2 withMasksToBounds:YES withViwe:_headerView];
    [authenticationBtn setTitle:@"实名认证" forState:UIControlStateNormal];
    [authenticationBtn setTitleColor:getColor(greenBGColor)  forState:UIControlStateNormal];
    authenticationBtn.titleLabel.font = DEF_FontSize_16;
    [authenticationBtn addTarget:self action:@selector(authenticationBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.authenticationBtn = authenticationBtn;
    [_headerView addSubview:authenticationBtn];
    //分割线
    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(whiteImg.left, whiteImg.bottom, whiteImg.width, 1/WIDTH_6_SCALE)];
    lineView.backgroundColor = getColor(@"f7f7f7");
    [_headerView addSubview:lineView];
    //下面白色背景
    UIView * whiteBGView = [[UIView alloc] initWithFrame:CGRectMake(whiteImg.left, lineView.bottom, whiteImg.width, 61/WIDTH_6_SCALE)];
    whiteBGView.backgroundColor = [UIColor whiteColor];
    //得到view的遮罩路径
    UIBezierPath *maskBottomPath = [UIBezierPath bezierPathWithRoundedRect:whiteBGView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10,10)];
    //创建 layer
    CAShapeLayer *maskBottomLayer = [[CAShapeLayer alloc] init];
    maskBottomLayer.frame = whiteImg.bounds;
    //赋值
    maskBottomLayer.path = maskBottomPath.CGPath;
    whiteBGView.layer.mask = maskBottomLayer;
    [_headerView addSubview:whiteBGView];
    for (int i = 0; i<3; i++) {
        //标题
        UILabel * titleLab = [[UILabel alloc] initWithFrame:CGRectMake(whiteBGView.width / 3 * i, 12/WIDTH_6_SCALE, whiteBGView.width/3, 14/WIDTH_6_SCALE)];
        titleLab.tag = 2000 + i;
        [self label:titleLab withFont:DEF_FontSize_13 withText:nil withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentCenter withView:whiteBGView withBGColor:[UIColor clearColor]];
        //内容
        UILabel * contentLab = [[UILabel alloc] initWithFrame:CGRectMake(whiteBGView.width / 3 * i, titleLab.bottom + 12/WIDTH_6_SCALE, whiteBGView.width/3, 14/WIDTH_6_SCALE)];
        contentLab.tag = 3000 + i;
        [self label:contentLab withFont:DEF_FontSize_13 withText:nil withTextColor:getColor(greenBGColor) withTextAlignment:NSTextAlignmentCenter withView:whiteBGView withBGColor:[UIColor clearColor]];
    }
    UILabel * joinDaysTitleLab = (UILabel *)[whiteBGView viewWithTag:2000];
    joinDaysTitleLab.text = @"加入(天)";
    self.joinDaysContentLab = (UILabel *)[whiteBGView viewWithTag:3000];
    self.joinDaysContentLab.text = @"1";
    UILabel * helpPersonsTitleLab = (UILabel *)[whiteBGView viewWithTag:2001];
    helpPersonsTitleLab.text = @"帮助(人)";
    self.helpPersonsContentLab = (UILabel *)[whiteBGView viewWithTag:3001];
    self.helpPersonsContentLab.text = @"1";
    UILabel * accountitleLab = (UILabel *)[whiteBGView viewWithTag:2002];
    accountitleLab.text = @"余额(元)";
    self.accountContentLab = (UILabel *)[whiteBGView viewWithTag:3002];
    self.accountContentLab.text = @"1";
    for (int i = 0; i<2; i++) {
        UIView * borderView = [[UIView alloc] initWithFrame:CGRectMake(whiteBGView.width/3 * (i+1), 16/WIDTH_6_SCALE, 1, whiteBGView.height - 32/WIDTH_6_SCALE)];
        borderView.backgroundColor = getColor(@"f7f7f7");
        [whiteBGView addSubview:borderView];
    }
    //组头
    UILabel * sectionTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(15/WIDTH_6_SCALE, bgImg.bottom, 96/WIDTH_6_SCALE, _headerView.height - bgImg.height)];
    [self label:sectionTitleLab withFont:DEF_FontSize_13 withText:@"我的家庭计划" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:_headerView withBGColor:[UIColor clearColor]];
    //生效人数
    self.validNumsLab = [[UILabel alloc] initWithFrame:CGRectMake(5/WIDTH_6_SCALE + sectionTitleLab.right, sectionTitleLab.top, 100/WIDTH_6_SCALE, sectionTitleLab.height)];
    [self label:self.validNumsLab withFont:DEF_FontSize_11 withText:@"10人权益生效中" withTextColor:getColor(@"9b9b9b") withTextAlignment:NSTextAlignmentLeft withView:_headerView withBGColor:[UIColor clearColor]];
    [_headerView addSubview:self.validNumsLab];
    //为家人添加
    UILabel * addFamilyLab = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 81/WIDTH_6_SCALE, sectionTitleLab.top, 81/WIDTH_6_SCALE, sectionTitleLab.height)];
    [self label:addFamilyLab withFont:DEF_FontSize_11 withText:@"为家人添加" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:_headerView withBGColor:[UIColor clearColor]];
    //加号
    int plusImgW = 8/WIDTH_6_SCALE;
    UIImageView * plusImg = [[UIImageView alloc] initWithFrame:CGRectMake(addFamilyLab.left - plusImgW - 6/WIDTH_6_SCALE, 0, plusImgW, plusImgW)];
    plusImg.centerY = addFamilyLab.centerY;
    plusImg.image = [UIImage imageNamed:@"add_shi_icon"];
    [_headerView addSubview:plusImg];
    //加号
    UIButton * plusBtn = [[UIButton alloc] initWithFrame:CGRectMake(plusImg.left, addFamilyLab.top, addFamilyLab.right - plusImg.left, addFamilyLab.height)];
    plusBtn.backgroundColor = [UIColor clearColor];
    [plusBtn addTarget:self action:@selector(plusBtnClic) forControlEvents:UIControlEventTouchUpInside];
    [_headerView addSubview:plusBtn];
    //助人记录
    UIButton * helpRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.joinDaysContentLab.left, 0, self.joinDaysContentLab.width * 2, whiteBGView.height)];
    [helpRecordBtn setBackgroundColor:[UIColor clearColor]];
    [helpRecordBtn addTarget:self action:@selector(helpRecordBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [whiteBGView addSubview:helpRecordBtn];
    //余额明细
    UIButton * accountRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(helpRecordBtn.right, 0, self.joinDaysContentLab.width, helpRecordBtn.height)];
    [accountRecordBtn setBackgroundColor:[UIColor clearColor]];
    [accountRecordBtn addTarget:self action:@selector(accountRecordBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [whiteBGView addSubview:accountRecordBtn];
    //喇叭图像
    UIImageView * trumpetImg = [[UIImageView alloc] initWithFrame:CGRectMake(whiteBGView.left, whiteBGView.bottom + 16/WIDTH_6_SCALE, 19/WIDTH_6_SCALE, 19/WIDTH_6_SCALE)];
    trumpetImg.image = [UIImage imageNamed:@"trumpet_icon"];
    [_headerView addSubview:trumpetImg];
    //了解更多文字
    UILabel * learnMoreLab = [[UILabel alloc] initWithFrame:CGRectMake(trumpetImg.right + 10/WIDTH_6_SCALE, 0, whiteBGView.width - 15/WIDTH_6_SCALE, trumpetImg.height)];
    learnMoreLab.centerY = trumpetImg.centerY;
    [self label:learnMoreLab withFont:DEF_FontSize_13 withText:@"了解更多关于博帮平台的咨询" withTextColor:[UIColor whiteColor] withTextAlignment:NSTextAlignmentLeft withView:_headerView withBGColor:[UIColor clearColor]];
    //箭头
    UIButton * arrowBtn = [[UIButton alloc] initWithFrame:CGRectMake(whiteBGView.right - 10/WIDTH_6_SCALE, 0, 10/WIDTH_6_SCALE, 12/WIDTH_6_SCALE)];
    arrowBtn.centerY = learnMoreLab.centerY;
    [arrowBtn setImage:[UIImage imageNamed:@"next_bai_icon"] forState:UIControlStateNormal];
    [_headerView addSubview:arrowBtn];
    //覆盖按钮
    UIButton * coverBtn = [[UIButton alloc] initWithFrame:CGRectMake(trumpetImg.left, trumpetImg.top, arrowBtn.right - trumpetImg.left, trumpetImg.height)];
    [coverBtn setBackgroundColor:[UIColor clearColor]];
    [coverBtn addTarget:self action:@selector(coverBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [_headerView addSubview:coverBtn];
}

#pragma mark - action
- (void)plusBtnClic{
    NSLog(@"为家人添加");
    AddFamilyViewController * vc = [[AddFamilyViewController alloc] init];
    vc.hidesBottomBarWhenPushed  = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)coverBtnClick{
    NSLog(@"我的 - 计划详情");
    MyProjectDetailViewController * vc = [[MyProjectDetailViewController alloc] init];
    vc.hidesBottomBarWhenPushed  = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - tableViewDelegate和tableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MineTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MineTableViewCell class]) forIndexPath:indexPath];
    cell.getRightBlock = ^(NSString *rightID) {
        JoinProjectViewController * vc = [[JoinProjectViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    };
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
#pragma mark - action
- (void)helpRecordBtnClick{
    HelpRecordViewController * vc = [[HelpRecordViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.helpNum = self.helpPersonsContentLab.text;
    vc.joinNum = self.joinDaysContentLab.text;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)accountRecordBtnClick{
    AccountDetailViewController * vc = [[AccountDetailViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.accountContenStr = self.accountContentLab.text;
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)authenticationBtnClick:(UIButton *)sender{
//    if ([sender.titleLabel.text isEqualToString:@"实名认证"]) {
        MyCertificateViewController * vc = [[MyCertificateViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        vc.accountContentStr = self.accountContentLab.text;
        [self.navigationController pushViewController:vc animated:YES];
//    }else{
//        AuthenticationViewController * vc = [[AuthenticationViewController alloc] init];
//        vc.hidesBottomBarWhenPushed = YES;
//        [self.navigationController pushViewController:vc animated:YES];
//    }
    
}
- (void)settingBtnClick{
    NSLog(@"设置");
    SettingViewController * vc = [[SettingViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
/**
 2  * @method
 3  *
 4  * @brief 获取两个日期之间的天数
 5  * @param fromDate       起始日期
 6  * @param toDate         终止日期
 7  * @return    总天数
 8  */
+ (NSInteger)numberOfDaysWithFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate{
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    NSDateComponents * comp = [calendar components:NSCalendarUnitDay
                                             fromDate:fromDate
                                            toDate:toDate
                                           options:NSCalendarWrapComponents];
    NSLog(@" -- >>  comp : %@  << --",comp);
    return comp.day;
}

+ (CGFloat)contentLabelWidth:(NSString *)text{
    CGRect rectToFit = [text boundingRectWithSize:CGSizeMake(MAXFLOAT, 17/WIDTH_6_SCALE)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17.0f]}
                                          context:nil];
    return rectToFit.size.width;
}
@end
